import java.util.Formatter; // used to format string

/**
 * @author Pedro J Toro
 * CSC8050 Design and Analysis of Algorithms 
 */
public class Point {
	private double x;
	private double y;

	/**
	 * Default constructor.
	 * @param x, x value of point
	 * @param y, y value of point
	 */
	public Point(double x, double y) {
		this.x = x;
		this.y = y;
	}

	/**
	 * Gets the x value of the point.
	 * @return the x
	 */
	public double getX() {
		return x;
	}

	/**
	 * Sets the x value of the point.
	 * @param x, the x to set
	 */
	public void setX(double x) {
		this.x = x;
	}

	/**
	 * Gets the y value of the point
	 * @return the y
	 */
	public double getY() {
		return y;
	}

	/**
	 * Sets the y value of the point
	 * @param y, the y to set
	 */
	public void setY(double y) {
		this.y = y;
	}

	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	/**
	 * Override for equals method. Returns true if Point values are equal to each other,
	 * false otherwise.
	 */
	public boolean equals(Object arg0) {
		if (arg0 instanceof Point) {
			Point thatPoint = (Point) arg0;
			
			// check if x y values equal
			return ((this.getX() == thatPoint.getX()) && (this.getY() == thatPoint.getY()));
		}

		return false;
	}

	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	/**
	 * Override for toString method. Returns a formated string with the x y values of the point.
	 */
	public String toString() {
		Formatter formatter = new Formatter();

		// format string output
		formatter.format("% .1f % .1f", this.getX(), this.getY());

		return formatter.toString();
	}

}